<div id="content">

 #{if flash.success}
    <p class="success">${flash.success}</p>
 #{/if}
<table style="width:100%;"><tr>
<td><h2>&{'managerequesttype.title'}</h2></td>
<td style="text-align:right">

	<a id="addrequesttype" href="#">&{'managerequesttype.add'}</a>
	
	</td>
</tr></table>


<table class="tableau">
<tr>
  <th>&{'table.requesttype.id'}</th>
  <th>&{'table.requesttype.describe'}</th>
  <th></th>
</tr>


#{list items:requestType, as:'request'}
<tr class="${request_parity}">
  <td>${request.getId()}</td>
  <td>${request.getDescription()}</td>
  <td align="center" >
  	<a href="#" onclick="update(${request.getId()})"><img src="@{'public/images/edit.png'}" width="25" height="25"/></a>
  	<a href="#" onclick="deleteType(${request.getId()})"><img src="@{'public/images/trash.png'}" width="25" height="25"/></a>
  </td>
  
  
</tr>
#{/list}
</table>
</div>

<script>
	$(function() {
		
		$("#addrequesttype").button().click(function() {
			// Define Create Action
			var createAction = #{jsAction @ManageRequestType.edit() /}

			// Call Create Action
			$.post(createAction(), function(data) {
				// Prepend Results to the List
				
				$('#content').replaceWith(data);
			});
		});
		
	});

	
	
</script>
<script>
//suppression d'un requestType
function deleteType(id) {
	
	var createAction = #{jsAction @ManageRequestType.deleteRequestType(':requestId') /}
	// Call Create Action
	$.post(createAction({requestId:id}), function(data) {
		// Prepend Results to the List
		$('#content').replaceWith(data);
	});
}

//mise a jour d'un requestType
function update(id) {
	
	var createAction = #{jsAction @ManageRequestType.edit(':requestId') /}
	//Call Create Action
	$.post(createAction({requestId:id}), function(data) {
		// Prepend Results to the List
		$('#content').replaceWith(data);
	});
	}
</script>
